﻿using System;
using System.Collections.Generic;
using System.Data;
using eTMS.Controllers.CaHocService;
using eTMS.Controllers.GiaoVienService;
using eTMS.Controllers.KhuNhaService;
using eTMS.Controllers.LichHocLopTinChiService;
using eTMS.Controllers.PhanCongGiangDayService;
using eTMS.Controllers.PhongHocService;
using eTMS.Controllers.ThuTrongTuanService;
using eTMS.Controllers.TietHocService;
using eTMS.Controllers.TrungTamDaoTaoService;

namespace eTMS.Controllers
{
    public class LichHocLopTinChiController : LichHocLopTinChiControllerBase
    {
        public LichHocLopTinChiController()
            : base()
        {
        }
        public DataTable TableTime { get; set; }
        public List<PhongHocEntity> TableLocation{ get; set;}
        public DataTable TableCourse { get; set; }
        public List<GiaoVienEntity> ListGiaoVien { get; set; } 
        public void LoadGiaoVienByMonHoc(List<int>ListMonHoc_ID)
        {
            PhanCongGiangDayService.PhanCongGiangDayServiceClient w=new PhanCongGiangDayServiceClient();
            List<int> ls = (new List<PhanCongGiangDayEntity>(w.SelectAllFilter("MonHoc_ID IN(" + string.Join(",", ListMonHoc_ID.ConvertAll<string>(Convert.ToString).ToArray()) + ")"))).ConvertAll<int>(delegate(PhanCongGiangDayEntity oConvert) { return oConvert.GiaoVien_ID; });
            ListGiaoVien = GiaoVienController.ListGiaoVienStatic.FindAll(delegate(GiaoVienEntity oFind) { return ls.Contains(oFind.GiaoVien_ID); });

        }
        public List<LichHocLopTinChiEntity> ListLichDaoTao { get; set; }
        public void LoadLichDaoTao(List<int>lsLopTinChi,List<int> ListTuanHoc_ID)
        {
            ListLichDaoTao = new List<LichHocLopTinChiEntity>(dao.SelectAllFilter("LopTinChi_ID IN(" + string.Join(",", lsLopTinChi.ConvertAll<string>(Convert.ToString).ToArray()) + ") AND TuanHoc_ID IN(" + string.Join(",", ListTuanHoc_ID.ConvertAll<string>(Convert.ToString).ToArray()) + ")"));
        }
        public List<LichHocLopTinChiEntity> FindByTietPhongHoc(int Thu_ID,int TietHoc_ID,int PhongHoc_ID)
        {
            if (ListLichDaoTao == null) return new List<LichHocLopTinChiEntity>();
            return ListLichDaoTao.FindAll(delegate(LichHocLopTinChiEntity oFind) { return oFind.TietHoc_ID.Equals(TietHoc_ID) && oFind.ThuTrongTuan_ID.Equals(Thu_ID) && oFind.PhongHoc_ID.Equals(PhongHoc_ID); });
        }
       
    }
}
